package com.dexgdx.game.manager;

import java.util.List;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect;
import com.badlogic.gdx.utils.Array;
import com.dexgdx.game.Game;

public class ParticleManager {

	public static void loadParticlesFromJSON(){
		
		ParticleEffect p = new ParticleEffect();
		p.load(Gdx.files.internal("data/particles/small_missile/particle.p"), Gdx.files.internal("data/particles/small_missile"));
		Game.particleData.dexMissileParticleEffectPool = new ParticleEffectPool(p, 0, 4);

		ParticleEffect p2 = new ParticleEffect();
		p2.load(Gdx.files.internal("data/particles/trail/particle.p"), Gdx.files.internal("data/particles/trail"));
		Game.particleData.dexTrailParticleEffectPool = new ParticleEffectPool(p2, 30, 70);
	}
	
	public static PooledEffect obtainFromDexMissileParticleEffectPool(){
		return Game.particleData.dexMissileParticleEffectPool.obtain();
	}
	
	public static void freeToDexMissileParticleEffectPool(PooledEffect pooledEffect){
		Game.particleData.dexMissileParticleEffectPool.free(pooledEffect);
	}
	
	public static PooledEffect obtainFromDexTrailParticleEffectPool(){
		return Game.particleData.dexTrailParticleEffectPool.obtain();
	}
	
	public static void freeToDexTrailParticleEffectPool(PooledEffect pooledEffect){
		Game.particleData.dexTrailParticleEffectPool.free(pooledEffect);
	}
	
	public static void freeAllToDexTrailParticleEffectPool(Array<PooledEffect> pooledEffects){
		Game.particleData.dexTrailParticleEffectPool.freeAll(pooledEffects);
	}
}
